package com.luoke.handler.response;

import com.luoke.connect.GameWebSocketClient;
import com.luoke.constants.SubmoduleTypeConstant;
import com.luoke.service.response.BattleResponseService;
import com.luoke.service.response.impl.BattleResponseServiceImpl;
import com.luoke.result.Result;

/**
 * 战斗响应处理层，分发对应响应
 */
public class BattleResponseHandler {

    private BattleResponseService battleResponseService = new BattleResponseServiceImpl() ;

    /**
     * 该方法处理模块的服务端响应的分发与处理
     * @param gameWebSocketClient 使用该对象与服务端通信
     * @param result 服务端返回的对象
     */
    public void handler(GameWebSocketClient gameWebSocketClient, Result result) {
        if (result.getCommand().equals(SubmoduleTypeConstant.SHOW_USER_WAIT_ONLINE_NAME)){ //展示在线人数(该方法暂时未使用)
            battleResponseService.showUserOnlineName(gameWebSocketClient,result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.SHOW_WAIT_FOR_USER)) { //展示在等待区的玩家
            battleResponseService.showWaitForUser(gameWebSocketClient,result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.INITIATE_BATTLE_REQUEST)) { //处理发起对战后的服务端响应
            battleResponseService.battleRequest(gameWebSocketClient, result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.ACCEPT_BATTLE_INVITATION)) { //处理从服务端收到的对战邀请
            battleResponseService.acceptBattleRequest(gameWebSocketClient, result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.MATCH_BATTLE)) { //对于随机匹配服务端响应的处理
            battleResponseService.matchBattle(gameWebSocketClient, result);
        }else if (result.getCommand().equals(SubmoduleTypeConstant.OPPONENT_ROUND_COMPLETED)) {
            battleResponseService.opponentRoundCompleted(gameWebSocketClient, result);
        }else if (result.getCommand().equals(SubmoduleTypeConstant.SHOW_USER_PET_INFO)) {
            battleResponseService.showUserPetInfo(gameWebSocketClient, result);
        }else if (result.getCommand().equals(SubmoduleTypeConstant.BATTLE_QUIT)){
            battleResponseService.battleQuit(gameWebSocketClient,result);
        } else if (result.getCommand().equals(SubmoduleTypeConstant.EXPERIENCE)) {
            battleResponseService.experienceResponse(gameWebSocketClient,result);
        }

    }
}
